package org.budo.lock.distributed.service.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * @author limingwei2
 */
public class AbstractRedisDistributedLockService {
    private JedisPool jedisPool;

    /**
     * 未释放的锁的自动过期时间，单位秒
     */
    private Integer lockExpireSeconds = 30;

    public Integer getLockExpireSeconds() {
        return lockExpireSeconds;
    }

    public void setLockExpireSeconds(Integer lockExpireSeconds) {
        this.lockExpireSeconds = lockExpireSeconds;
    }

    public JedisPool getJedisPool() {
        return jedisPool;
    }

    public void setJedisPool(JedisPool jedisPool) {
        this.jedisPool = jedisPool;
    }

    public Jedis getJedis() {
        return this.getJedisPool().getResource();
    }

    @SuppressWarnings("deprecation")
    public void returnJedis(Jedis jedis) {
        this.getJedisPool().returnResource(jedis);
    }
}